
package gui.panels;

import gui.MainFrame;
import gui.listeners.GuiActionEvent;
import gui.listeners.GuiActionEventType;
import gui.model.DrinkModel;
import gui.panels.components.MmiButton;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

/**
 *
 * @author JtR
 */
public class SelectCoffeePanel extends GuiPanel {
    private MmiButton coffeButton, cappuchinoButton, espressoButton;
    
    public SelectCoffeePanel(MainFrame parent) {
        super(parent, BackgroundType.COFFEE);
    }
    
    @Override
    protected void initComponents() {
        cappuchinoButton = new MmiButton("res/kaffeepause/Cappuchino.png", 413);
        cappuchinoButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                fireGuiActionEvent(new GuiActionEvent(GuiActionEventType.CHOSE_CAPPUCHINO));
            }
        });
        constraints.insets = new Insets(255, 534, 0, 0);
        add(cappuchinoButton, constraints);
        
        espressoButton = new MmiButton("res/kaffeepause/espresso.png", 190);
        espressoButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                fireGuiActionEvent(new GuiActionEvent(GuiActionEventType.CHOSE_ESPRESSO));
            }
        });
        constraints.insets = new Insets(341, 255, 0, 0);
        add(espressoButton, constraints);
        
        coffeButton = new MmiButton("res/kaffeepause/schwarzerKaffee.png", 270);
        coffeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                fireGuiActionEvent(new GuiActionEvent(GuiActionEventType.CHOSE_COFFEE_BLACK));
            }
        });
        constraints.insets = new Insets(107, 340, 0, 0);
        add(coffeButton, constraints);
    }

    @Override
    public String getDescription() {
        return "Wie möchten Sie Ihren Kaffee trinken?";
    }

    @Override
    public void updateFields() {
    }

    @Override
    public boolean getPreviousButtonEnabled() {
        return true;
    }

    @Override
    public boolean getNextButtonEnabled() {
        return DrinkModel.getInstance().getCoffee() != null;
    }

    @Override
    public String getName() {
        return "COFFEE_NAME";
    }

    @Override
    public GuiPanel getNextPanel() {
        switch(DrinkModel.getInstance().getCoffee()) {
            case BLACK_COFFEE:
            case CAPPUCHINO:
                return parent.selectSizePanel;
            case ESPRESSO:
                return parent.selectEspressoSizePanel;
            default:
                throw new RuntimeException();
        }
    }

    @Override
    public GuiPanel getPreviousPanel() {
        return parent.selectDrinkPanel;
    }
}
